<!DOCTYPE html>

<html lang="en">
	
	<head>

		<meta charset="utf-8" />

		<title>密码管理</title>

		<!-- IE -->
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<!-- 设置 viewport -->
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<!-- 兼容国产浏览器的高速模式 -->
		<meta name="renderer" content="webkit">
		<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->

		<!-- BEGIN 全局样式 -->
		<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
		<link href="../../lib/bootstrap-3.3.7-dist/css/bootstrap.css" rel="stylesheet" type="text/css" />	
		<link rel="stylesheet" type="text/css" href="../../css/common.css" />
		<!--<link rel="stylesheet" type="text/css" href="../../lib/bootstrap-table/src/bootstrap-table.css"/>-->
		<!-- END 全局样式 -->
		<style type="text/css">
			.img-QRC{
				width: 100px;
				height: 100px;
			}
		</style>
	</head>

	

	<body class="">
		
		<div class="container-fluid">
			<div class="searchBox mt-10">
				<div class="form-group" style="width: 200px;margin: 0 auto;">				   
				    <div class="input-group">
				      <input type="text" class="form-control" id="keyword" placeholder="关键字">
				      <div class="input-group-addon">
				      	<a title="search" class="btn-search">
				      		<span class="glyphicon glyphicon-search"></span>
				      	</a>
				      </div>
				    </div>
			  	</div>
			</div>
			<div class="mb-10 mt-10 parentClear">
				<div class="btn-group lf">					
					<!--<a class="btn btn-success btn-export"  title="export">
						<span class="glyphicon glyphicon-export"></span>导出
					</a>-->
				</div>
				<div class="rf pt-10">
					<span>总共</span>
					<b class="nTotal">0</b>
					<span>条</span>
				</div>
			</div>
			<table class="table table-bordered table-hover table-striped table-vertical" id="table1">
				<thead>
					<tr class="text-c">
						<th width="50">编号</th>
						<th>真实姓名</th>
						<th>账号</th>
						<th>原始密码</th>	
						<th>
							二维码
						</th>
						<th width="150">操作</th>
					</tr>
					
				</thead>
				<tbody>
					
				</tbody>
			</table>
		</div>
		
		
		
		
		<!--核心脚本sss-->
		<script src="../../lib/jquery/1.9.1/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../lib/layer/2.4/layer.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../lib/laypage/1.2/laypage.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../lib/bootstrap-3.3.7-dist/js/bootstrap.js" type="text/javascript" charset="utf-8"></script>

		<script src="../../js/common/jsrsasign-all-min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/common/crypto-js.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/common/jquery.myPlugIn_v1.0.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/common/localstorage-ie.js" type="text/javascript" charset="utf-8"></script>

		<!--[if lt IE 9]>
		<script src="../../js/excanvas.min.js"></script>
		<script src="../../js/respond.min.js"></script>  
		<![endif]-->
		<!--核心脚本eee-->
		
		<script type="text/javascript">
			//函数调用区域====================================================================================
			
			
			//初始化分页东西
			$("#table1").paging({
				url: url_join("password/list"),
				data: {
					limit:10,
					page:1,
					keyword:$("#keyword").val()
				},
				type: "post",
				eleTotal:$(".nTotal"),//总数dom节点
				callBack: function(data) {
					console.log(data);
					createTable(data,$("#table1"))
				}
			});
			
			//模糊搜索
			$(".btn-search").on("click",function(){
				$("#table1").paging({
					url: url_join("password/list"),
					data: {
						limit:10,
						page:1,
						keyword:$("#keyword").val()
					},
					type: "post",
					eleTotal:$(".nTotal"),//总数dom节点
					callBack: function(data) {
						console.log(data);
						createTable(data,$("#table1"))
					}
				});
			});
		//重置密码
			$("body").on("click",".btn-reset-pwd",function(){
				var nId = $(this).parents("tr").attr("data-id");
				layer.confirm("确认重置密码？",function(){
					fnAjax.method_4(
						url_join("password/reset"),
						{uid:nId},
						"post",
						function(data){
							layer.msg("操作成功",{time:1500},function(){
								window.location.reload();
							});
						}
					);
				});
			});
			
			//查询二维码
			$("body").on("click",".btn-show-BQ",function(){
				var sUrl = $(this).attr("data-href");
				var real_name =$(this).parent("td").siblings(".real_name").text();
				layer.open({
					type: 2,
				    title: real_name + "的二维码",
				    area: ['100%', '100%'],
				    shade: 0.8,
				    closeBtn: 1,
				    shadeClose: true,
				    content: sUrl,
					end:function(){
						window.location.reload();
					}
				});
			});
			
			//导出表格
			$(".btn-export").on("click",function(){
				window.location.href = url_join("password/export");
			});
			
			//函数封装区域======================================================================================================
			/*
			创建表格 
			@param data 主要渲染数据
			@param containter 主要渲染数据的jq容器
			 * */
			function createTable(data,containter){
				containter.find("tbody tr").remove();
				$.each(data.items, function(i,v) {
					var sTr = '<tr class="text-center" data-id="'+ (v.id && v.id) +'">'+
								'<td class="td-num">'+ ((data.current-1)*data.limit+(i+1)) +'</td>'+
								'<td class="real_name">'+ v.real_name +'</td>'+
								'<td>'+ v.username +'</td>'+
								'<td class="">'+
									v.password +
								'</td>'+		
								'<td class="td-QRC">'+
//									'<img src="'+ url_join("password/qrCode") +'?pwd='+ localStorage.getItem("schoolId") +'&uid='+ (v.id && v.id) +'" class="img-QRC"/>'+
									'<a data-href="'+ url_join("password/qrCode") +'?pwd='+ JSON.parse(localStorage.getItem("userMsg")).school_id +'&uid='+ (v.id && v.id) +'"  class="btn-show-BQ">点击查看用户二维码</a>'+
								'</td>'+	
								'<td class="td-option">'+
									'<a class="btn-reset-pwd" title="other">'+
										'<span class="glyphicon glyphicon-repeat"></span>重置密码'+
									'</a>'+											
								'</td>'+
							'</tr>';
					containter.append($(sTr));
				});
			}
		</script>
	</body>

</html>